package com.bocai.kelalacar.net;



import com.google.gson.Gson;
import com.google.gson.GsonBuilder;

import okhttp3.OkHttpClient;
import retrofit2.Retrofit;
import retrofit2.adapter.rxjava.RxJavaCallAdapterFactory;
import retrofit2.converter.gson.GsonConverterFactory;

import static com.bocai.kelalacar.net.Url.BASE_URL;


/**
 * 作者 yuanfei on 2017/2/23.
 * 邮箱 yuanfei221@126.com
 */

public class LocalRetrofit {

    private static Retrofit retrofit;

    public LocalRetrofit(OkHttpClient okHttpClient) {

        Gson gson = new GsonBuilder()
                .setLenient()
                .create();

        retrofit = new Retrofit.Builder()
                .baseUrl(BASE_URL)
                .client(okHttpClient)
                .addCallAdapterFactory(RxJavaCallAdapterFactory.create())
                .addConverterFactory(GsonConverterFactory.create(gson))
                .build();
    }


    public Retrofit getRetrofit() {
        return retrofit;
    }
}
